﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace skvote
{
    public partial class admin_subject_add : System.Web.UI.Page
    {
        private OleDbConnection connection = new conn().CreateConnection();
        protected void Page_Load(object sender, EventArgs e)
        {
            function.check();
        }

        protected void submit_Click(object sender, EventArgs e)
        {
            try
            {
                string subject = function.nohtml(Request["subject"]);
                string qx = function.nohtml(Request["qx"]);
                OleDbCommand cmd = new OleDbCommand("SELECT subject FROM XH_Subject WHERE subject=\"" + subject + "\"", connection);
                OleDbDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    function.showErr("该主题已经存在了",Response,Request);
                    dr.Close();
                }
                else
                {
                    dr.Close();
                    cmd.CommandText = "INSERT INTO XH_Subject([subject],[QX]) values(\"" + subject + "\",\""+ qx + "\")";
                    cmd.CommandType = CommandType.Text;
                    cmd.ExecuteNonQuery();
                    function.successMsg("主题添加成功");
                }
            }
            finally
            {
                connection.Close();
            }
        }
    }
}
